package demo01;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-11
 * Time: 19:38
 */
public class Test02 {
    //实现Runnable接口,重写run，匿名内部类实现
    public static void main(String[] args) {
        Thread t =new Thread(new Runnable() {
            @Override
            public void run() {
                while(true) {
                    System.out.println("多线程");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }, "线程1");  //给线程命名
        t.start();
    }
}
